package it.sd.pwframework.business.service.impl;

import java.util.List;

import it.sd.pwframework.business.bean.common.RemoteMovieBean;
import it.sd.pwframework.business.service.ImdbBatchService;
import it.sd.pwframework.business.service.ImdbService;
import it.sd.pwframework.persistence.common.CommonSession;

import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("imdbBatchService")
public class ImdbBatchServiceImpl implements ImdbBatchService {

    protected Logger log = org.slf4j.LoggerFactory.getLogger(this.getClass());
    
    @Autowired
    private CommonSession commonSession;

    @Autowired
    private ImdbService imdbService;

    private static final String IMDB_SOURCE_CODE = "IMDB";
    private static final String IMDB_MEDIA_TYPE  = "FILM";
    
	public void updateImdbMovieList() throws Exception {
		
		// scarica la lista dei film in formato XML
		List<RemoteMovieBean> lista = imdbService.downloadListMovies();
		
		// aggiorna ogni singolo XML scaricato
		for (RemoteMovieBean imdbMovieBean : lista) {
			aggiornaMovie(imdbMovieBean);
		}
		
		
	}
	
	
}
